<template>
    <div>
        <div class="top">
            <el-button class="add">新建分类</el-button>
        </div>
        <div class="listlen">
            <i class="el-icon-s-unfold"></i>  数据列表
        </div>
        <el-table :data="List"
        style="width: 100%"
        row-key="id"
        border
        :tree-props="{children: 'children'}"
        > 
            
            <el-table-column
            prop="catename"
            label="分类名称"
            sortable
            width="380">
            </el-table-column>
            <el-table-column
            prop="fid"
            label="级别"
            sortable
            width="180">
            </el-table-column>
            <el-table-column
            label="是否末级"
            sortable
            width="80">
            </el-table-column>
            <el-table-column
            prop="des"
            label="首页显示"
            sortable
            width="80">
            </el-table-column>
            <el-table-column
            prop="id"
            label="分类显示"
            sortable
            width="180">
            </el-table-column>
            <el-table-column
            prop="id"
            label="分类排序"
            sortable
            width="180">
            </el-table-column>
            <el-table-column
            label="分类显示"
            sortable
            width="180">
            <template slot-scope="scope">
                <el-button type="text" size="small" @click="editlist(scope.row)">编辑</el-button>
                <el-button type="text" size="small" @click="open(scope.row.id)">删除</el-button>    
            </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import { GetCate } from '@/api/shop';

export default {
    data(){
        return {
            List:[]
        }
    },
    created(){
        this.getCate()
    },
    methods:{
        // cab(arr){
        //     arr.forEach(item=>{
        //         if(item.children){
        //             var arr =item.children
        //             this.cab(arr)
        //         }
        //         item.fid+=1
        //     })
        // },
        // 获取分类数据
        getCate(){
            GetCate()
            .then(res=>{
                this.List=res.data.list
                // this.cab(this.List)
                console.log(res);
            })
        }
    }
}
</script>
<style lang="scss" scoped>
.listlen{
    height: 50px;
    line-height: 50px;
    padding-left: 20px;
}
.top{
    padding: 10px 0;
}
.add{
    background-color: #3399cc;
    color: white;
    width: 150px;
    height: 50px;
}
</style>